<template>
    <div id="systemdisplay">
        <div class="jx-content">
            <div class="display-item">
                <div class="item-title">
                    <i class="iconfont icon-xiangmutixi"></i>
                    课程体系
                </div>
                <div class="item-input">
                    <el-radio-group v-model="diplay1">
                        <el-radio label="1">显示</el-radio>
                        <el-radio label="0">隐藏</el-radio>
                    </el-radio-group>
                </div>
            </div>
            <div class="display-item">
                <div class="item-title">
                    <i class="iconfont icon-gangwei"></i>
                    岗位技能
                </div>
                <div class="item-input">
                    <el-radio-group v-model="diplay2">
                        <el-radio label="1">显示</el-radio>
                        <el-radio label="0">隐藏</el-radio>
                    </el-radio-group>
                </div>
            </div>
            <el-button class="button-style saveBtn" @click="save">保存</el-button>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                diplay1: '1',
                diplay2: '1'
            }
        },
        created() {
            let self = this
            self.initDisplay()
        },
        methods: {
            initDisplay(){
                let self = this

                self.$http.get('/tes/unauthorized/config?keys=courseSystemShow&keys=indexSkill').then(response => {
                    let res = response.data
                    if(res.code === 200){
                        self.diplay1 = res.data.courseSystemShow[0].keyValue
                        self.diplay2 = res.data.indexSkill[0].keyValue
                    }else{
                        self.$message.error(res.message)
                    }
                }).catch(err => {
                    console.log(err)
                })
            },
            // 保存
            save(){
                let self = this
                let data = []
                data = [
                    {
                        "keyValue": ""+self.diplay1+"",
                        "keyWord": "courseSystemShow"
                    },
                    {
                        "keyValue": ""+self.diplay2+"",
                        "keyWord": "indexSkill"
                    }
                ]
                self.$http.put('/tes/unauthorized/config',data).then(response => {
                    let res = response.data
                    if(res.code === 200){
                        self.$message({
                            message: '保存成功',
                            type: 'success'
                        })
                    }else{
                        self.$message.error(res.message)
                    }
                }).catch(err => {
                    console.log(err)
                })
            }
        }
    }
</script>

<style lang="scss" scope>
    .jx-content{
        margin-top: 20px;
    }
    .display-item{
        margin-bottom: 70px;
        .item-title{
            font-size: 16px;
            color: #727272;
            i{
                font-size: 22px;
                vertical-align: -webkit-baseline-middle;
                margin-right: 5px;
            }
        }
        .item-input{
            padding-left: 35px;
        }
    }
    .el-radio__inner{
        border-color: #dcdfe6;
    }
    #systemdisplay{
        .button-style{
            width: 90px;
            margin: 50px auto;
            display: block;
        }
    }
</style>
